home *** CD-ROM | disk | FTP | other *** search
- /*
- * The original copyright owners of the accompanying source code files have
- * agreed to place such code into the public domain. Accordingly, anyone
- * who receives or obtains a copy of such source code is freely entitled to
- * reproduce, use and otherwise exploit such code (including the right to
- * make derivative works), at his/her own risk and expense, without any
- * obligation or liability to the original copyright owners.
- *
- * We would appreciate (but do not require) that the following message be
- * included in any derivative works:
- *
- * "Portions of this program were developed by Peter Broadwell, Rob Myers
- * and Robin Schaufler while working in Silicon Valley."
- *
- * The accompanying source code files and related documentation materials
- * are distributed on an "AS IS" basis, without any warranties or
- * guarantees of any kind. All implied warranties, including the implied
- * warranties of merchantability and of fitness for any particular purpose,
- * are expressly disclaimed.
- */
- /*
- * basic geometric primitive types
- */
- typedef struct {
- long x, y, z;
- } point;
-
- typedef struct {
- long x, y;
- } point2d;
-
- typedef struct {
- Coord x, y;
- } point2df;
-
- typedef struct {
- point2d orig;
- point2d extent;
- } rectangle;
-
- typedef struct {
- point2df orig;
- point2df extent;
- } rectanglef;
-
- typedef struct {
- point orig;
- point extent;
- } cube;
-
- typedef struct {
- Coord x, y, z;
- } fpoint;
-
- #ifndef TRUE
- #define TRUE 1
- #endif /* TRUE */
- #ifndef FALSE
- #define FALSE 0
- #endif /* FALSE */
-
- #define abs(val) ((val) >= 0 ? (val) : -(val))
- #define sign(val) ((val) >= 0 ? 1 : -1)
- #define odd(val) ((val) & 01 ? TRUE : FALSE)
- #define min(val1,val2) ((val1) < (val2) ? (val1) : (val2))
- #define max(val1,val2) ((val1) > (val2) ? (val1) : (val2))
-
- #define setrect(r,x1,y1,x2,y2) {(r)->orig.x = x1; \
- (r)->orig.y = y1; \
- (r)->extent.x = x2; \
- (r)->extent.y = y2; }
-
- #define setpt2d(r,x1,y1) {(r)->x = x1; (r)->y = y1; }
-
- #define PI 3.14159265358979323844
- #define DEG(x) ((float)x*(float)180/PI)
- #define RAD(x) ((float)x*PI/(float)180)
- #define HYPOT(a,b) sqrt(fabs((float)((a)*(a) + (b)*(b))))
-
-